<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\product\model;

class LayerCol {
	
	static $_TSPEC;
	public $pid = null;
	public $name = null;
	public $mode = null;
	public $displayForm = null;
	public $layerObj = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'pid'
			),
			2 => array(
			'var' => 'name'
			),
			3 => array(
			'var' => 'mode'
			),
			4 => array(
			'var' => 'displayForm'
			),
			5 => array(
			'var' => 'layerObj'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['pid'])){
				
				$this->pid = $vals['pid'];
			}
			
			
			if (isset($vals['name'])){
				
				$this->name = $vals['name'];
			}
			
			
			if (isset($vals['mode'])){
				
				$this->mode = $vals['mode'];
			}
			
			
			if (isset($vals['displayForm'])){
				
				$this->displayForm = $vals['displayForm'];
			}
			
			
			if (isset($vals['layerObj'])){
				
				$this->layerObj = $vals['layerObj'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'LayerCol';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("pid" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->pid); 
				
			}
			
			
			
			
			if ("name" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->name);
				
			}
			
			
			
			
			if ("mode" == $schemeField){
				
				$needSkip = false;
				$input->readByte($this->mode); 
				
			}
			
			
			
			
			if ("displayForm" == $schemeField){
				
				$needSkip = false;
				$input->readByte($this->displayForm); 
				
			}
			
			
			
			
			if ("layerObj" == $schemeField){
				
				$needSkip = false;
				
				$this->layerObj = new \com\vip\product\model\LayerObj();
				$this->layerObj->read($input);
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		if($this->pid !== null) {
			
			$xfer += $output->writeFieldBegin('pid');
			$xfer += $output->writeI32($this->pid);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->name !== null) {
			
			$xfer += $output->writeFieldBegin('name');
			$xfer += $output->writeString($this->name);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->mode !== null) {
			
			$xfer += $output->writeFieldBegin('mode');
			$xfer += $output->writeByte($this->mode);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->displayForm !== null) {
			
			$xfer += $output->writeFieldBegin('displayForm');
			$xfer += $output->writeByte($this->displayForm);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->layerObj !== null) {
			
			$xfer += $output->writeFieldBegin('layerObj');
			
			if (!is_object($this->layerObj)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $this->layerObj->write($output);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>